package ejb;

import entity.Message;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
@LocalBean
public class MessagesBean {

    @PersistenceContext(unitName = "tryBeans-ejbPU")
    private EntityManager em;

    public List<Message> retrieve() {
        return em.createNamedQuery("Message.findAll").getResultList();
    }

    public void persist(Object object) {
        em.persist(object);
    }
}
